﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace Skyhook.Core
{
    class XNAGameComponent : DrawableGameComponent
    {
        public delegate void NoArgsEvent();
        public delegate void TimeEvent(GameTime time);

        public event NoArgsEvent OnLoadContent = null;
        public event NoArgsEvent OnUnloadContent = null;
        public event NoArgsEvent OnInitialize = null;
        public event TimeEvent OnUpdate = null;
        public event TimeEvent OnDraw = null;

        public XNAGameComponent(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
        }

        protected override void LoadContent()
        {
            if (OnLoadContent != null)
            {
                OnLoadContent();
            }

            base.LoadContent();
        }

        protected override void UnloadContent()
        {
            if (OnUnloadContent != null)
            {
                OnUnloadContent();
            }

            base.UnloadContent();
        }

        public override void Initialize()
        {
            if (OnInitialize != null)
            {
                OnInitialize();
            }

            base.Initialize();
        }

        public override void Update(GameTime time)
        {
            if (OnUpdate != null)
            {
                OnUpdate(time);
            }

            base.Update(time);
        }

        public override void Draw(GameTime time)
        {
            if (OnDraw != null)
            {
                OnDraw(time);
            }

            base.Draw(time);
        }
    }
}
